<template>
	<div class="page">
		<c-title :hide="false" text="就诊人详情"></c-title>
		<div class="box">
			<van-cell-group inset style="margin: 0;">
				<!-- 输入任意文本 -->
				<van-field v-model="name" label="就诊人" placeholder="请输入就诊人姓名" />
				<!-- 输入手机号，调起手机号键盘 -->
				<van-field v-model="id_card" label="有效证件" placeholder="请输入就诊人身份证件" />
				<!-- 允许输入正整数，调起纯数字键盘 -->
				<van-field v-model="phone" type="tel" label="手机号" placeholder="请输入就诊人手机号" />
			
			</van-cell-group>
		</div>
	<div class="submit" @click="submit">修改就诊人</div>
	</div>
</template>

<script>
	import {
		Toast
	} from 'vant';
	export default {
		data() {
			return {
				data: {},
				id: '',
				name: '',
				id_card: '',
				phone: '',
				ids: ''
			}
		},
		methods:{
			getdata(){
				$http
					.post("plugin.hft-yh.api.index.patient_info", {
						patient_id: this.id,
				
					})
					.then(response => {
						console.log(response)
						if (response.result === 1) {
							this.name = response.data.name
							this.id_card = response.data.id_card
							this.phone = response.data.phone
							this.ids = response.data.id
							// this.data = response.data
						} else {
							Toast(response.msg);
						}
					})
					.catch(error => {
						console.log(error);
					});
			},
			init() {
				this.show = false
				this.name = ''
				this.id_card = ''
				this.phone = ''
			},
			submit(){
				
				$http
					.post("plugin.hft-yh.api.index.edit_patient", {
						patient_id:this.ids,
						name: this.name,
						phone: this.phone,
						id_card: this.id_card
				
					})
					.then(response => {
						console.log(response)
						if (response.result === 1) {
							Toast('修改成功！')
							// this.init()
							this.getdata()
							// this.data = response.data
						} else {
							Toast(response.msg);
						}
					})
					.catch(error => {
						console.log(error);
					});
			}
		},
		activated() {
			this.id = this.$route.query.ids
			this.getdata()
			console.log(this.$route.query)
		}
	}
</script>

<style scoped lang="scss">
	.page{
		.submit{
			position: fixed;
			bottom: 0;
			width: 100%;
			background-color: #EB5648;
			color: #fff;
			text-align: center;
			line-height: 3rem;
			font-size: 1rem;
			
		}
		.box{
			// padding: 0.5rem;
		}
	}
</style>
